﻿using System;

namespace ByteSite.Common
{
    /// <summary>
    /// 文件属性
    /// </summary>
    public class FileAttribute
    {
        /// <summary>
        /// 文件名
        /// </summary>
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// 所在文件夹
        /// </summary>
        public string Directory
        {
            get;
            set;
        }
        /// <summary>
        /// 文件类型(文本文档)
        /// </summary>
        public string Type
        {
            get {
                string name = string.Empty;
                switch (Extension.ToLower())
                {
                    case "": name = ""; break;
                    default: name = Extension.ToUpper().Replace(".", "") + "文件"; break;
 
                }
                return name;
            }
        }
        /// <summary>
        /// 文件扩展名(txt、doc)
        /// </summary>
        public string Extension
        {
            get;
            set;
        }
        /// <summary>
        /// 物理路径
        /// </summary>
        public string Path
        {
            get;
            set;
        }
        /// <summary>
        /// 文件大小 1.26GB  2.33 MB
        /// </summary>
        public string StrSize
        {
            get
            {
                string name = string.Empty;
                if (Size < 1024)
                {
                    name = Size + "B";
                }
                else if (Size >= 1024 && Size < 1048576)
                {
                    name = ((Double)Size / (Double)1024).ToString("f2") + "KB";
                }
                else if (Size >= 1048576 && Size < 1073741824)
                {
                    name = ((Double)Size / (Double)1048576).ToString("f2") + "MB";
                }
                else if (Size >= 1073741824 && Size < 1099511627776)
                {
                    name = ((Double)Size / (Double)1073741824).ToString("f2") + "GB";
                }
                else if (Size >= 1099511627776 && Size < 1125899906842624)
                {
                    name = ((Double)Size / (Double)1099511627776).ToString("f2") + "PB";
                }
                else
                {
                    name = "N/A";
                }
                return name;
            }
        }
        /// <summary>
        /// 文件大小
        /// </summary>
        public long Size
        {
            get;
            set;
        }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime
        {
            get;
            set;
        }
        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime UpdateTime
        {
            get;
            set;
        }
        /// <summary>
        /// 访问时间
        /// </summary>
        public DateTime ReadTime
        {
            get;
            set;
        }
        /// <summary>
        /// 只读
        /// </summary>
        public bool IsReadOnly
        {
            get;
            set;
        }
        /// <summary>
        /// 隐藏
        /// </summary>
        public bool IsHidden
        {
            get;
            set;
        }

    }
}
